from django.conf.urls.defaults import patterns, include, url
from django.views.generic import DetailView, ListView
from polls.models import Poll

handler404 = 'polls.views.handler404'

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'mydjango.views.home', name='home'),
    # url(r'^mydjango/', include('mydjango.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

	##
	# url(r'^$', 'index'),
	# url(r'^(?P<poll_id>\d+)/$', 'detail'),
	# url(r'^(?P<poll_id>\d+)/result/$', 'result'),
	# url(r'^(?P<poll_id>\d+)/vote/$', 'vote'),
	##
	url(r'^$',
        ListView.as_view(
            queryset=Poll.objects.order_by('-pub_date')[:5],
            context_object_name='latest_poll_list',
            template_name='polls/index.html')),
    url(r'^(?P<pk>\d+)/$',
        DetailView.as_view(
            model=Poll,
            template_name='polls/detail.html')),
    url(r'^(?P<pk>\d+)/results/$',
        DetailView.as_view(
            model=Poll,
            template_name='polls/result.html'),
			name='poll_results'),
    url(r'^(?P<poll_id>\d+)/vote/$', 'vote'),
)
